package practise.dao;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import practise.domain.User;

import java.util.List;

public interface IUserDao {

    @Select("select * from user")
    List<User> findAll();

    @Insert("insert into user(username,address,sex,birthday)values (#{username},#{address},#{sex},#{birthday})")
    void saveUser(User user);

    @Update("update user set username=#{username}, address=#{address}, sex=#{sex}, birthday=#{birthday} where id=#{id}")
    void updataUser(User user);

    @Delete("delete from user where id=#{userid}")
    void deleteUser(Integer userId);

    @Select("select * from user where id = #{userid}")
    User findById(Integer userId);
    //模糊查询
    @Select("select * from user where username like #{name};")
    List<User> findByName(String username);
}
